﻿using System.ComponentModel.DataAnnotations;
using FlyingHat.Model.Enums;
using Microsoft.EntityFrameworkCore;

namespace FlyingHat.Core.Entities
{
    /// <summary>
    /// 用户表
    /// </summary>
    [Index(nameof(UserName), nameof(Phone), IsUnique = true, Name = "UserName_Phone")]
    public class User : ModifyEntity
    {
        /// <summary>
        /// 用户名
        /// </summary>
        [Required, StringLength(50)]
        public string UserName { get; set; } = string.Empty;

        /// <summary>
        /// 真实姓名
        /// </summary>
        [Required, StringLength(50)]
        public string RealName { get; set; } = string.Empty;

        /// <summary>
        /// 密码
        /// </summary>
        [Required, StringLength(50)]
        public string Password { get; set; } = string.Empty;
        /// <summary>
        /// 盐值
        /// </summary>
        [Required, StringLength(100)]
        public string Salt { get; set; } = string.Empty;

        /// <summary>
        /// 头像
        /// </summary>
        [StringLength(500)]
        public string Avatar { get; set; } = string.Empty;

        /// <summary>
        /// 手机号
        /// </summary>
        [StringLength(11)]
        public string Phone { get; set; } = string.Empty;

        /// <summary>
        /// 状态天数，小于0 表示永久，配合状态
        /// </summary>
        public int BlockDay { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        public DateTime LastLoginTime { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        public bool IsDeleted { get; set; }
        /// <summary>
        /// 性别
        /// </summary>
        public Gender Gender { get; set; }

        /// <summary>
        /// 用户状态
        /// </summary>
        public UserStatus UserStatus { get; set; }

        /// <summary>
        /// 用户身份
        /// </summary>
        public Identity Identity { get; set; }
    }
}
